<?php
declare(strict_types=1);

namespace think\admin\test\validate;

use think\admin\Validate;

class User extends Validate
{
    /**
     * 验证规则
     * @var array
     */
    protected $rule = [
        'username' => 'require|length:4,20|alphaNum',
        'password' => 'require|length:6,20',
        'email' => 'require|email',
        'captcha' => 'require|length:4'
    ];

    /**
     * 错误信息
     * @var array
     */
    protected $message = [
        'username.require' => '用户名不能为空',
        'username.length' => '用户名长度必须在4-20个字符之间',
        'username.alphaNum' => '用户名只能是字母和数字',
        'password.require' => '密码不能为空',
        'password.length' => '密码长度必须在6-20个字符之间',
        'email.require' => '邮箱不能为空',
        'email.email' => '邮箱格式不正确',
        'captcha.require' => '验证码不能为空',
        'captcha.length' => '验证码长度必须是4位'
    ];

    /**
     * 验证场景
     * @var array
     */
    protected $scene = [
        'login' => ['username', 'password', 'captcha'],
        'register' => ['username', 'password', 'email', 'captcha']
    ];
} 